package texas_holdem.data;

import java.util.Vector;

import texas_holdem.data.Card.CardNumber;
import texas_holdem.data.Card.CardType;

public class Deck {

	private static Deck  _instance = null;
	private Vector<Card> _deck;
	
	
	private Deck()
	{
		_deck = new Vector<Card>();
		for (CardNumber num : CardNumber.values())
			for (CardType type : CardType.values())
				_deck.add(new Card(num, type));
	}
	
	public Vector<Card> getCopyOfDeck()
	{
		Vector<Card> copy = new Vector<Card>();
		for (Card c:_deck)
			copy.add(c);
		return copy;
	}
	public static Deck getInstance()
	{ 
		if (_instance == null)
			_instance = new Deck();
		return _instance;
	}
	
	public Card getCard(CardNumber num, CardType type)
	{		
		for (Card c : _deck)
		{
			if (c.getNumber() == num && c.getType() == type)
				return c;
		}
		return null;
	}
	public Card getRandomCard()
	{
		return _deck.get((int)(Math.random()*_deck.size()));
	}
}
